package thread;

/**
 * Created with IntelliJ IDEA.
 * Description: isAlive()方法测试
 * User: 王圆豪
 * Date: 2025-04-23
 * Time: 1:05
 */
public class Demo8 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 3; i++) {
                System.out.println("Hello thread!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        thread.start();

        while (true) {
            System.out.println(thread.isAlive());
            Thread.sleep(1000);
        }
    }
}
